import React, { Component } from 'react';
import { StyleSheet, View, Text, TouchableOpacity, Image, Modal } from 'react-native';
import navigationSeevice from '../../../../../../components/navigation/navigationSeevice';
import { style } from '../../../../../../theme/style';
import HTTP from '../../../../../../utils/http';
import { API, API_GENERATE } from '../../../../../../config/api';
import { GLOBAL } from '../../../../../../config/global';
import { orderStyle, commonStyle } from '../../_common/style';

const scale = GLOBAL.SCALE;
export class AddressCpt extends Component {
	constructor(props) {
		super(props);
		this.state = {
		}
	}

	render () {
		let { data, index, length, ifEdit, editPress, delPress } = this.props || {};
		let { updateBy, mobileNo, provinceName, cityName, areaName, detailAddress, addressName, fullName } = data || {};
		let mobile = ifEdit ? mobileNo : mobileNo && (mobileNo.substring(0, 3) + '****' + mobileNo.substring(7, 11));
		// let address = `${provinceName || ''} ${cityName || ''} ${areaName || ''} ${detailAddress || ''}。${addressName || ''}`;
		let address = `${fullName} ${detailAddress || ''}。${addressName || ''}`;
		return (
			<View style={[styles.item, index !== (length - 1) ? styles.borderBottom : null]}>
				<View style={styles.row}>
					<Text style={[styles.commonText, styles.bold]}>{updateBy || '--'}</Text>
					<Text style={[styles.commonText, styles.bold]}>{mobile || ''}</Text>
				</View>
				<View style={[styles.row, { justifyContent: 'space-between', paddingTop: 10 * scale }]}>
					<View style={styles.tipTextView}>
						<Text style={styles.tipText}>{address}</Text>
					</View>
					{
						ifEdit ?
							<View style={[styles.row, styles.borderLeft,]}>
								<Text style={[styles.tipEdit, { color: style.color.themeColor }]} onPress={() => editPress && editPress()}>编辑</Text>
								<Text style={[styles.tipEdit, { color: '#E02020' }]} onPress={() => delPress && delPress()}>删除</Text>
							</View>
							: null
					}
				</View>
			</View>
		)
	}
}

const styles = StyleSheet.create({
	item: {
		paddingTop: 14 * scale,
		paddingBottom: 14 * scale,
	},
	borderBottom: {
		borderBottomWidth: 1 * scale,
		borderBottomColor: '#E3E7F0'
	},
	borderLeft: {
		borderLeftWidth: 1 * scale,
		borderLeftColor: '#E3E7F0'
	},
	row: {
		flexDirection: 'row',
		alignItems: 'flex-start'
	},
	commonText: {
		fontSize: 14 * scale,
		color: '#34475F',
		marginRight: 10 * scale,
	},
	bold: {
		fontWeight: 'bold'
	},
	tipTextView: {
		marginRight: 10 * scale,
		flexWrap: 'wrap',
		width: 240 * scale,
	},
	tipText: {
		fontSize: 12 * scale,
		color: '#848A96',
		lineHeight: 16 * scale
	},
	tipEdit: {
		fontSize: 12 * scale,
		color: '#848A96',
		paddingLeft: 8 * scale
	}
})